package io.gitee.yth.design.pattern.test.core.pattern.creational.builder;

import org.junit.jupiter.api.Test;
import io.gitee.yth.design.pattern.test.core.pattern.creational.builder.traditional.CommonHouse;
import io.gitee.yth.design.pattern.test.core.pattern.creational.builder.traditional.HighBuilding;

/**
 * @author yth
 * @since 2023-04-24-16:56
 */
public class Client {

    /**
     * 传统方式
     * <p>
     * 没有设计缓存层对象，扩展性和维护性不好
     * 把产品和产品的创建过程耦合
     */
    @Test
    public void test1() {
        CommonHouse commonHouse = new CommonHouse();
        commonHouse.build();
        HighBuilding highBuilding = new HighBuilding();
        highBuilding.build();
    }

    /**
     * 使用建造者模式
     */
    @Test
    public void test2() {
        HouseDirector director = new HouseDirector(new CommonHouseBuilder());
        House house = director.construct();
        System.out.println(house);

        director = new HouseDirector(new HighHouseBuilder());
        house = director.construct();
        System.out.println(house);
    }

    @Test
    public void test3() {
        Appendable builder = new StringBuilder();
    }

}
